<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
  <head>    
    <title>修改密码</title>
    <meta name="description" content="">
    <meta name="author" content="">
    <%@include file="../common/common_ui.jsp" %>
    <script type="text/javascript">
    	function save(){
    		var pwd0=$("#pwd0");
    		var pwd1=$("#pwd1");
    		var pwd2=$("#pwd2");
    		if(jQuery.trim(pwd0.val())==""){
    			salert2("旧密码不能为空",function (){pwd0.focus();});    			
    			return;
    		}
    		if(jQuery.trim(pwd1.val())==""){
    			salert2("新密码不能为空",function (){pwd1.focus();});    			
    			return;
    		}
    		if(pwd1.val()!=pwd2.val()){
    			salert2("两次输入密码不一致",function (){pwd1.focus().select();});    			
    			return;
    		}
    		$.post("<%=path%>/userInfo/updatePwd.do",{pwdnew:pwd1.val(),password:pwd0.val(),pwdconfirm:pwd2.val()},function (a,b){
    			var msg=a.message;    			
    			if(msg=='success'){
    				salert2('密码修改成功');
    				window.close();
    			}else{
    				salert2(msg);
    			}
    		});    		
    	}
    </script>
  </head>

  <body>
	    <c:if test="${!empty error}">
	    	<script type="text/javascript">
    		salert2("${error}");	
    		</script>
	    </c:if>
	    <form  name="frm" id="f2" class="definewidth m20" action="<c:url value="userInfo/updatePwd.do"/>" method="post">		
	        <table class="table table-bordered table-hover definewidth m10">
	        	<tr>
					<td>旧密码:</td>
					<td>
						<input id="pwd0" name="password" type="password" class="abc input-default" maxLength="50" placeholder="旧密码" value="${passWord}"/>
					</td>
				</tr>
				<tr>
					<td>新密码:</td>
					<td><input id="pwd1" name="pwdnew" type="password" 
					class="abc input-default" value="${pwdnew}" style="width:150px" maxLength="50"/></td>
				</tr>
				<tr>
					<td>确认密码:</td>
					<td><input id="pwd2" name="pwdnew2" type="password" 
					class="abc input-default" value="${pwdnew2}" style="width:150px" maxLength="50"/></td>
				</tr>
				
				<tr class="btn_space">
					<td>&nbsp;</td>
					<td>
						<input class="btn btn-primary" type="button" onclick="save()" value="确认"/> 
						<input type="button" class="btn" onclick="window.close();" value="关闭" />
					</td>
				</tr>
	        </table>
	        <input type="hidden" name="userName" value="<sec:authentication property="name"/>" />
		</form>

  </body>
</html>
